FROM ubuntu:20.04

# 添加自定义源
RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ trusty main universe" >> /etc/apt/sources.list 

# 更新和升级系统
RUN apt-get update && apt-get upgrade --assume-yes

# 安装软件属性工具和 OpenJDK PPA
RUN apt-get install --assume-yes software-properties-common
RUN add-apt-repository ppa:openjdk-r/ppa
RUN apt-get update

RUN apt-get install --assume-yes locales
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
ENV LC_ALL en_US.UTF-8

# 设置时区
ENV TZ=Asia/Shanghai
RUN apt-get install -y tzdata && \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
    echo $TZ > /etc/timezone && \
    dpkg-reconfigure -f noninteractive tzdata 

# 创建用户
ARG user=test
RUN useradd --create-home --no-log-init --shell /bin/bash ${user} \
    && adduser ${user} sudo \
    && echo "${user}:1" | chpasswd

# 安装基础开发工具和库
RUN apt-get install --assume-yes \
    build-essential \
    git \
    gperf \
    curl \
    wget \
    sudo \
    python3 \
    python3-pip \
    bc \
    cpio \
    rsync \
    unzip \
    zip \
    libssl-dev \
    liblz4-tool \
    libncurses5-dev \
    libxml2-utils \
    xsltproc \
    zlib1g-dev \
    gcc-multilib \
    g++-multilib \
    libc6-dev-i386 \
    lib32ncurses5-dev \
    lib32z1-dev \
    uuid-dev \
    chrpath \
    diffstat \
    binfmt-support \
    qemu-user-static \
    live-build \
    bison \
    flex \
    fakeroot \
    cmake \
    device-tree-compiler \
    zstd \
    openjdk-8-jdk \
    clang \
    libyaml-dev \
    expect \
    mingw32 \
    cgpt \
    texinfo \
    patchelf \
    chrpath \
    gawk \
    bsdmainutils  \
    repo git ssh make gcc libssl-dev liblz4-tool expect g++ patchelf chrpath gawk texinfo chrpath diffstat binfmt-support qemu-user-static live-build bison flex fakeroot cmake  gcc-multilib g++-multilib unzip device-tree-compiler python-pip libncurses5-dev zstd rsync device-tree-compiler bc time  \
    libgmp-dev  libmpc-dev expect-dev 

# gcc-aarch64-linux-gnu  \
# g++-aarch64-linux-gnu  \

# 安装 Python 2（如果需要）
RUN update-alternatives --install /usr/bin/python python /usr/bin/python2 27001

# 克隆 LZ4 仓库并安装
RUN git clone https://github.com/lz4/lz4.git --depth 1 -b v1.9.4
WORKDIR /lz4
RUN make install -j8

# 清理缓存
RUN rm -rf /var/lib/apt/lists/*
RUN rm -rf /lz4

WORKDIR /home/${user}

# 切换到普通用户
USER ${user}

